/**  
 * All rights Reserved, Designed By <a href="www.itttq.com" target="_blank">www.itttq.com</a>
 * @date:   2018-01-6 11:42:21
 * @Copyright: 2017 <a href="www.itttq.com" target="_blank">www.itttq.com</a> Inc. All rights reserved. 
 */
package com.itttq.gshop.h5.controller.sys;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.itttq.gshop.domain.po.SysNoticePo;
import com.itttq.gshop.domain.to.ResultPageTo;
import com.itttq.gshop.generic.connector.ISysNoticeConnector;
import com.itttq.gshop.generic.controller.GenericController;

@RestController
@RequestMapping("notice")
public class NoticeController extends GenericController {
	private static final long serialVersionUID = 555162098081133619L;
	@Autowired
	private ISysNoticeConnector sysNoticeConnector;
	
	/**
	 * 根据条件查询SysNoticePo对象，并分页
	 * 
	 * @param sysNotice
	 * @param request
	 * @return
	 * @Author 迷蝶
	 * @return ModelAndView
	 */
	@RequestMapping("notices.html")
	public ModelAndView getNotices(HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/sys/notices");
		SysNoticePo notice = new  SysNoticePo();
		this.getPpt(request, notice);
		ResultPageTo<SysNoticePo> rpt = sysNoticeConnector.getSysNotices(notice);
		this.getPageMv("notices", mv, rpt);
		mv.addObject("notice", notice);
		return mv;
	}
	/**
	 * 跳转到查看页面
	 * @param id
	 * @return
	 */
	@RequestMapping("{id}.html")
	public ModelAndView viewNotice(@PathVariable("id") Integer id) {
		ModelAndView mv = new ModelAndView("/sys/notice");
		if(id != null) {
			mv.addObject("notice", sysNoticeConnector.getSysNotice(id));
		}
		mv.addObject("op", "view");
		return mv;
	}
	
}